#include <stdio.h>
#include <string.h>

void expand(char s1[], char s2[]);
char out[1000];

int main()
{
    char input[] = "-A-Z0-9a-z-";
    expand(input, out);
    printf("input = %s\n  out = %s\n",input, out);

    return 0;
}

void expand(char s1[], char s2[])
{
    int i, j;
    for (i = 0, j = 0; s1[i] != '\0'; i++)
    {
        if (s1[i] == '-')
        {
            if (i == 0)
                s2[j++] = s1[i];
            else
            {
                s2[j] = s1[i - 1];

                if (s1[i + 1] >= 'a' && s1[i + 1] <= 'z')
                {
                    while (s2[j++] < s1[i + 1])
                    {
                        s2[j] = s2[j - 1] + 1;
                    }
                }
                else if (s1[i + 1] >= '0' && s1[i + 1] <= '9')
                {
                    while (s2[j++] < s1[i + 1])
                    {
                        s2[j] = s2[j - 1] + 1;
                    }
                }
                else if (s1[i + 1] >= 'A' && s1[i + 1] <= 'Z')
                {
                    while (s2[j++] < s1[i + 1])
                    {
                        s2[j] = s2[j - 1] + 1;
                    }
                }
            }
        }
    }

    if (s1[strlen(s1) - 1] == '-')
        s2[j++] = '-';

    s2[j] = '\0';
}